<?php
// | 初始化
// +----------------------------------------------------------------------
// | Author: carl <469714167@qq.com>
// +----------------------------------------------------------------------
// | Datetime: 2017-8-28 9:40:12
// +----------------------------------------------------------------------

namespace app\shop\controller\v1;
use org\MonModel;
use think\Controller;
use think\Db;
use think\Request;
class init extends Controller
{
    protected $id;
    protected $info;


    protected function _initialize()
    {
        parent::_initialize();
        $request = Request::instance();
        $param = input('post.');
        $api_log['return'] = json_encode([$request->action()=>$param]);
        $api_log['time'] = date('Y/m/d/H/i/s',time());
        db::name('sh_api_log')->insert($api_log);
        header('Access-Control-Allow-Origin:*');
        $this->auth();
    }

    public function auth(){
        $param = input('post.');
        if (isset($param['user_id'])) {
            $this->id = $param['user_id'];
            $this->info = Db::table('slzd_user')->where('id', $this->id)->find();
            if(empty($this->info)) {
                 returnApi(true,'用户不存在',['row'=> []],200);
            }
        }else{
            returnApi(true,'用户id未传',['row'=> []],200);
        }
    }

    public function saveLocation()
    {
        nearDriver('121.4879','31.24916');
    }
}